package com.axc.common.utils;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * 获取配置文件中的路径
 *
 */
public class GetContentPath {

    public String getContentPaht() {
        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
        HttpServletRequest request = sra.getRequest();
        // System.out.println("---- 可返回站点的根路径----"+request.getContextPath()); //
        // 可返回站点的根路径。也就是项目的名字
        String contentPaht = request.getContextPath();
        return contentPaht;
    }


    public String getUrlPaht() {
        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
        HttpServletRequest request = sra.getRequest();
        // System.out.println("---- 可返回站点的根路径----"+request.getContextPath()); //
        // 可返回站点的根路径。也就是项目的名字
        String contentPaht = request.getRequestURI();
        return contentPaht;
    }
}
